#define _CRT_SECURE_NO_WARNINGS 1
#include"Heap.h"


void test()
{
	Heap hp;
	HeapInit(&hp);

	HeapPush(&hp, 1);
	HeapPush(&hp, 2);
	HeapPush(&hp, 3);
	HeapPush(&hp, 4);
	HeapPush(&hp, 5);

	while (!HeapEmpty(&hp))
	{
		printf("%d  ", HeapTop(&hp));
		HeapPop(&hp);
	}

	printf("\n");

	HeapDestory(&hp);
}

void testSort()
{
	int arr[] = { 6,5,7,8,9,4,3,10,2,1 };
	HeapSort(arr, 10);

	for (int i = 0; i < 10; i++)
		printf("%d  ", arr[i]);
}


void TestTopk()
{
	int n = 1000000;
	srand(time(0));
	const char* file = "data.txt";
	FILE* fin = fopen(file, "w");
	if (fin == NULL)
	{
		perror("fopen error");
		return;
	}

	for (int i = 0; i < n; ++i)
	{
		int x = (rand() + i) % 10000000;
		fprintf(fin, "%d\n", x);
	}
	fclose(fin);
	int* a = (int*)malloc(sizeof(int) * 10);

	PrintTopK(a, n, 10);

	for (int i = 0; i < 10; i++)
		printf("%d ", a[i]);
}

int main()
{
	//test();
	//testSort();

	TestTopk();
	return 0;
}